
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<div class="row-fluid">
    <div class="span12">
        <!-- BEGIN THEME CUSTOMIZER-->

        <!-- END THEME CUSTOMIZER-->
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <div style="clear:both; height:20px"></div>
        <ul class="breadcrumb">
            <li>
                <a href="index.html">Home</a>
                <span class="divider">/</span>
            </li>

            <li class="active">
            </li >
            <li class="active">Googleマップ                       
            </li>

        </ul>
        <!-- END PAGE TITLE & BREADCRUMB-->
        <div class="row-fluid">
            <div class="span12">


                <!-- BEGIN EXAMPLE TABLE widget-->

                <div class="control-group">
                    <?php
                    echo $this->Form->create('Camera', array(
                        'inputDefaults' => array(
                            'div' => 'control-group',
                            'label' => array(
                                'class' => 'control-label'
                            ),
                            'wrapInput' => 'controls'
                        ),
                        'class' => 'form-horizontal'
                    ));
                    ?>
                    <?php
                    echo $this->Form->input('Camera.CustId', array(
                        'label' => array(
                            'text' => 'お客様名'
                        ),
                        'empty' => false,
                        'options' => $this->Common->listCustomer(true),
                        'class' => 'span4',
                        'id' => 'search_customer',
                        'required' => false
                    ));
                    ?>
                    <?php
                    echo $this->Form->input('Camera.BuildId', array(
                        'label' => array(
                            'text' => '物件名'
                        ),
                        'empty' => false,
                        'options' => $this->Common->listBulding(),
                        'class' => 'span4',
                        'id' => 'search_building'
                    ));
                    ?>
                    <?php
                    echo $this->Form->input('Camera.CamName', array(
                        'placeholder' => 'カメラ名',
                        'class' => 'span4',
                        'type' => 'text',
                        'required' => false
                    ));
                    ?>
                    <div class="control-group required">
                        <label for="CameraName" class="control-label">
                            <button class="btn btn-success" type="submit">
                                <i class="icon-search icon-white"></i> 検索
                            </button>
                        </label>
                        <div class="controls required">
                        </div>
                    </div>
<?php echo $this->Form->end(); ?>
                </div>

                <div class="widget orange">
                    <div class="widget-title">
                        <h4><i class="icon-reorder"></i> Googleマップ</h4>
                        <span class="tools">
                            <a href="javascript:;" class="icon-chevron-down"></a>

                        </span>
                    </div>
                    <div class="widget-body">
                        <div id="gmap_basic" class="gmaps">
                            <?php
                            if (isset($map_options)):
                                echo $this->GoogleMap->map($map_options);
                                if (isset($buildings)) {
                                    foreach ($buildings as $key => $value) {
                                        echo $this->GoogleMap->addMarker("map_canvas", $key, $buildings[$key]['Building']['BuildAddress'], array(
                                            "showWindow" => true,
                                            "windowText" => "Marker",
                                            "markerTitle" => $buildings[$key]['Camera']['CamName'],
                                            "markerIcon" => "http://maps.google.com/mapfiles/marker.png",
                                            "markerShadow" => "http://maps.google.com/mapfiles/shadow50.png",
                                        ));
                                    }
                                }
                            endif;
                            ?>
                        </div>
                    </div>
                </div>
                <!-- END EXAMPLE TABLE widget-->


            </div>
        </div>
    </div>
</div>
<!-- END PAGE HEADER-->
<!-- BEGIN PAGE CONTENT-->
<script>
    $(document).ready(function() {
        //

        if ($("#search_customer").size() > 0) {
            getBuilding('<?php echo isset($_REQUEST['data']['Camera']['BuildId']) ? $_REQUEST['data']['Camera']['BuildId'] : "-1" ?>', 0);
        }
        $("#search_customer").on('change', function() {
            getBuilding(-1, 0);
        });

    });
</script>